<!--权限按钮组件-->
<!-- 组件使用示例:
    <auth-button size="small" type="primary":label="$t('fincrm.businessInfo')"
       @click="showCompany(scope.$index, scope.row)" menuCode="projectList" perms="projectListRemove">
    </auth-button>
-->
<template>
  <el-button v-if="hasPerms(menuCode, perms)" :size="size" :type="type"
    :loading="loading"
    :disabled="disabled"
    :title="title" :class="isColor(title)"
    :icon="icon"
    @click="handleClick">
    {{label}}
  </el-button>
</template>

<script>
// import { hasOperatorPermission } from '@/permission.js'
export default {
  name: 'AuthButton',
  props: {
    menuCode: { // 所属菜单Code-->全局唯一
      type: String,
      default: null
    },
    label: { // 按钮显示文本
      type: String,
      default: ''
    },
    size: { // 按钮尺寸
      type: String,
      default: 'mini'
    },
    type: { // 按钮类型
      type: String,
      default: null
    },
    loading: { // 按钮加载标识
      type: Boolean,
      default: false
    },
    disabled: { // 按钮是否禁用
      type: Boolean,
      default: false
    },
    perms: { // 按钮权限标识，外部使用者传入
      type: String,
      default: null
    },
    icon: { // 图标
      type: String,
      default: ''
    },
    title: { // 按钮作用
      type: String,
      default: ''
    }
  },
  data () {
    return {
    }
  },
  methods: {
    handleClick: function () {
      // 按钮操作处理函数
      this.$emit('click', {})
    },
    hasPerms: function (menuCode, perms) {
      // 根据权限标识进行权限判断
      // return hasOperatorPermission(menuCode, perms)
      return true
    },
    isColor (title) {
      let style
      if (title.indexOf('异常') !== -1) {
        style = 'btnyichang'
      } else if (title.indexOf('可疑') !== -1) {
        style = 'btnkeyi'
      }
      return style
    }
  },
  mounted () {
  }
}
</script>

<style>

</style>
